package newcall.com.newcalldemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.google.gson.Gson;
import com.m800.m800demo.R;

import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

public class TimeActivity extends AppCompatActivity {

    TextView tv_tip;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_time);
        tv_tip=findViewById(R.id.tv_tip);
    }

    public void onclick(View view) {
        switch (view.getId())
        {
            case R.id.btn_time:
               getTimeList();
                break;
        }
    }

    public void getTimeList()

    {

        Date begindate = TimeUtis.getInstance().getCurrentTime();
        List<DateItemDTO> dates =new ArrayList<>();
        for (int i = 0; i < 7; i++)
        {
            Date date =  TimeUtis.getInstance().getSpaceTime(begindate,i);
            DateItemDTO customDate = TimeUtis.getInstance().getCustomDate(date);
            dates.add(customDate);
        }


        tv_tip.setText("");
        for (DateItemDTO date :dates)
        {
//         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//         String format1 = format.format(date);
         tv_tip.setText(tv_tip.getText()+"\n"+new Gson().toJson(date));
        }
    }

    //






}
